/*
 * Copyright 2012 Jonathan St-Michel <jonathan@abiwebz.net>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.abiwebz.office.rm.database.security;


/**
 * LoginPanel is used to connect the end-user to the database.
 * 
 * @author Jonathan St-Michel <jonathan@abiwebz.net>
 */
public class LoginPanel extends javax.swing.JPanel {
   
    /**
     * Default LoginPanel constructor. Nothing special is done here, only 
     * loading components on the form.
     */
    public LoginPanel() {

        initComponents(); // Load every components

    }
    
    public String getUsername(){
        return this.tfUsername.getText();
    }
    
    public char[] getPassword(){
        return this.pfPassword.getPassword();
    }
    
     /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lIcon = new javax.swing.JLabel();
        lTitle = new javax.swing.JLabel();
        lDescription = new javax.swing.JLabel();
        sep1 = new javax.swing.JSeparator();
        lUsername = new javax.swing.JLabel();
        lPassword = new javax.swing.JLabel();
        pfPassword = new javax.swing.JPasswordField();
        chkRememberMe = new javax.swing.JCheckBox();
        tfUsername = new javax.swing.JTextField();

        setMaximumSize(new java.awt.Dimension(341, 32767));

        lIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/abiwebz/office/rm/database/resources/icons/password.png"))); // NOI18N
        lIcon.setText(org.openide.util.NbBundle.getMessage(LoginPanel.class, "LoginPanel.lIcon.text")); // NOI18N

        lTitle.setText(org.openide.util.NbBundle.getMessage(LoginPanel.class, "LoginPanel.lTitle.text")); // NOI18N

        lDescription.setText(org.openide.util.NbBundle.getMessage(LoginPanel.class, "LoginPanel.lDescription.text")); // NOI18N

        lUsername.setText(org.openide.util.NbBundle.getMessage(LoginPanel.class, "LoginPanel.lUsername.text")); // NOI18N

        lPassword.setText(org.openide.util.NbBundle.getMessage(LoginPanel.class, "LoginPanel.lPassword.text")); // NOI18N

        pfPassword.setText(org.openide.util.NbBundle.getMessage(LoginPanel.class, "LoginPanel.pfPassword.text")); // NOI18N

        chkRememberMe.setText(org.openide.util.NbBundle.getMessage(LoginPanel.class, "LoginPanel.chkRememberMe.text")); // NOI18N

        tfUsername.setText(org.openide.util.NbBundle.getMessage(LoginPanel.class, "LoginPanel.tfUsername.text")); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(sep1)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lUsername)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tfUsername))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lIcon)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lTitle)
                            .addComponent(lDescription, javax.swing.GroupLayout.DEFAULT_SIZE, 312, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lPassword)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pfPassword)
                            .addComponent(chkRememberMe))))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {lPassword, lUsername});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(lIcon))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(sep1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lUsername)
                    .addComponent(tfUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lPassword)
                    .addComponent(pfPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chkRememberMe, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox chkRememberMe;
    private javax.swing.JLabel lDescription;
    private javax.swing.JLabel lIcon;
    private javax.swing.JLabel lPassword;
    private javax.swing.JLabel lTitle;
    private javax.swing.JLabel lUsername;
    private javax.swing.JPasswordField pfPassword;
    private javax.swing.JSeparator sep1;
    private javax.swing.JTextField tfUsername;
    // End of variables declaration//GEN-END:variables

}
